package homework;

public class Account {
    private String account;
    private double balance;

    public Account() {
    }

    public Account(String account, double balance) {
        this.account = account;
        this.balance = balance;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public double getBalance() {
        return balance;
    }

    public void withdraw(double money) throws Exception{
        if (money<0){
            throw new Exception("越取你余额越多，想得美");
        }else if (money>balance){
            throw new Exception("取款金额不足，不支持当前取款操作");
        }else {
            balance-=money;
            System.out.println("取款成功，当前余额为"+balance+"元");
        }
    }
    public void save(double money) throws Exception{
        if (money<0){
            throw new Exception("越存余额越少，你愿意吗？");
        }else {
            balance+=money;
            System.out.println("存款成功，当前余额为"+balance+"元");
        }
    }
}
